<template>
	<view class="homeIndex">
		<basics ref="basics" v-if="PageCur=='basics'"></basics>
		<message v-if="PageCur=='component'"></message>
	    <plugin v-if="PageCur=='plugin'"></plugin>
		<myhome v-if="PageCur=='myhome'"></myhome>
		<view class="cu-bar tabbar bg-white shadow foot myhclass">
			<view class="action" @click="NavChange" data-cur="basics">
				<view class='cuIcon-cu-image'>
					<image class="myplugin" :src="'../../static/basics' + [PageCur == 'basics'?'_cur':''] + '.png'"></image>
				</view>
				<view :class="PageCur=='basics'?'text-pink':'text-gray'">建档</view>
			</view>
			<view class="action" @click="NavChange" data-cur="plugin">
				<view class='cuIcon-cu-image'>
					<image class="myplugin" :src="'../../static/hospitals' + [PageCur == 'plugin'?'_cur':''] + '.png'"></image>
				</view>
				<view :class="PageCur=='plugin'?'text-pink':'text-gray'">服务</view>
			</view>
			<view class="action" @click="NavChange" data-cur="component">
				<view class='cuIcon-cu-image'>
						<image class="myplugin" :src="'../../static/plugin' + [PageCur == 'component'?'_cur':''] + '.png'"></image>
				</view>
				<view :class="PageCur=='component'?'text-pink':'text-gray'">消息</view>
				
			</view>
			
			<view class="action" @click="NavChange" data-cur="myhome">
				<view class='cuIcon-cu-image'>
					<image class="myplugin" :src="'../../static/myhome' + [PageCur == 'myhome'?'_cur':''] + '.png'"></image>
				</view>
				<view :class="PageCur=='myhome'?'text-pink':'text-gray'">我的</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				PageCur: 'basics'
			}
		},
		async onPullDownRefresh() {
			// to doing..
			this.lodingtop();
			// 停止下拉刷新
		},
        onLoad(option) {
			var _this = this;
			if(option.code){
				uni.setStorage({
					//存储到本地
					key: "openid",
					data: option.code
				});
				this.$ajaxs
                .get("/mobile/v1/wechat/officialAccountAuth", {code:option.code})
                .then(res => {
                    if (res.status === 200) {
                    } else {
                        return false;
                    }
                });
			}
		
			
		},
		onShow() {
        	// if(this.PageCur=='basics'){
			// 	this.$refs.basics.getGpregnantList()
			// }
    	},
		methods: {
			lodingtop(){
				if(this.PageCur=='basics'){
					this.$refs.basics.getGpregnantList()
				}
				uni.stopPullDownRefresh();
			},
            NavChange: function(e) {
				this.PageCur = e.currentTarget.dataset.cur;
				if(this.PageCur=='component'){
					uni.setNavigationBarTitle({title:'我的消息'})
				}else{
					uni.setNavigationBarTitle({title:'幸孕妈'})
				}
			}
		}
	}
</script>

<style scoped>
.homeIndex{
	width: 100%;
   height: 100%;
}
.homeIndex .lg{
	font-size: 26upx;

}
.myhclass .cuIcon-likefill,
.myhclass .cuIcon-myfill,
.myhclass .cuIcon-homefill{
	color: #39b54a;
}
.myhclass .myplugin{
   width: 42upx !important;
   height: 42upx !important;
}
</style>
